package com.zsrt.java.day20170112.lh.daily.ch05;

import static org.junit.Assert.*;

import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

import org.junit.Test;

public class FileWriterTest {
	
	
	public static void main(String[] args) throws IOException {
		
		//1
		File file=new File("C:/a.txt");
		
		FileWriter fw=new FileWriter(file);
		
		String target="中深软通1612";
		
		/*char[] b=target.toCharArray();
		
		fw.write(b);*/
		
		fw.write(target);
		
		fw.close();
		
	}
	
	
	@Test
	public void homeWork() throws Exception {
		
		File file=new File("C:/HelloWorld.java");
		File on=new File("C:/BB.txt");
		
		FileReader fr=new FileReader(file);
		FileWriter fw=new FileWriter(on);
		
		int len=0;
		char[] b=new char[10];
		while((len=fr.read(b))!=-1){
			String st=new String(b,0,len);
			System.out.println(st);
			fw.write(st);
		}
		
		fw.close();
		fr.close();
		
	}
	
	

}
